package com.jic.manager.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.manager.mapper.CmsPageChannelMapper;
import com.jic.manager.entity.CmsPageChannel;
import com.jic.manager.service.CmsPageChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 页面渠道关系表
 * @author : 
 * @email : 
 * @since : 2020-03-05 12:00:46
 * @version : v1.0.0
 */
@Service
public class CmsPageChannelServiceImpl implements CmsPageChannelService{

    @Autowired
    private CmsPageChannelMapper cmsPageChannelMapper;

    @Override
    public long insert(CmsPageChannel cmsPageChannel) {
        long flag = cmsPageChannelMapper.insert(cmsPageChannel);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return cmsPageChannelMapper.delete(id);
    }

    @Override
    public long update(CmsPageChannel cmsPageChannel) {
        return cmsPageChannelMapper.update(cmsPageChannel);
    }

    @Override
    public CmsPageChannel queryByPrimaryKey(Long id){
        return cmsPageChannelMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<CmsPageChannel> query(CmsPageChannel cmsPageChannel){
        return cmsPageChannelMapper.query(cmsPageChannel);
    }

    @Override
    public PageResult<CmsPageChannel> queryPage(CmsPageChannel cmsPageChannel, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<CmsPageChannel> list = cmsPageChannelMapper.queryPage(startIndex, pageQuery.getLimit(), cmsPageChannel);
        long count = cmsPageChannelMapper.queryPageCount(cmsPageChannel);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}